Showing posts with label Microsoft Exchange. Show all posts

Set Automatic Individual Corporate Outlook Web App (OWA) Signatures in Exchange Online / Office 365 with PowerShell

An e-mail signature is part of your corporate branding. Having a professional, uniform e-mail signature across your organization increases recognizability, allows clients to quickly find contact information and allows your business to use it as a spot for advertising.

Requesting employees in a large organization to create and design similar signatures is nearly impossible. Check out this crazy before-picture of the situation in our health care organization. Complete with blue handwriting fonts and Comic Sans. Lovely. Fortunately there are software tools available, such as RES Workspace Manager, to set a default, corporate signature in Outlook, but these tools only support the full version of Outlook. As businesses are moving to the cloud, more and more applications, including Outlook, will be offered web-based only.

Automatic e-mail signature in Outlook 2013 generated by RES Workspace Manager

The larger part of our employees are kiosk users, who have access to Outlook Web App (OWA) only, as a component of Office 365. We would still like to prevent a signature mess like before and preconfigure uniform, corporate signatures.

PowerShell to the rescue! With PowerShell you can connect to Exchange Online using an administrative or service account and set OWA signatures. I've written a script that sets a template signature for everybody and also inputs their individual contact information by replacing specific variables in the HTML code, such as %DisplayName%, %Title%, %Phone% and so on, with the values from the appropriate Active Directory User Attributes.

Note: by design this script only sets automated signatures for users who have never set a signature before or who have cleared their signature. See "Final Remarks" for other options.

Instructions

  1. Download and extract SetOWASignatures.zip. Here's a link to view the code.
  2. Open SetOWASignatures.ps1 and replace "admin@<company>.onmicrosoft.com" with your Office 365/Exchange Online admin account.
  3. Securely save your password in an encrypted format in Password.txt in the root directory of the script. This is required to run the script without user interaction. You can use the following PowerShell command to generate the Password file:
    Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File "<path to root of script>\Password.txt"
    Verify that your directory security is set up correctly.
  4. Modify Signature.html to reflect your brand. The variables %DisplayName%, %Title%, %Phone% and so on, will be automatically replaced by the script with the appropriate Active Directory User Attributes.
  5. Run the script (it will not modify existing signatures as only unset or cleared signatures will be set).

Automatic email signature in Outlook Web App (OWA) in Office 365.

(Optional) Schedule the script to run periodically

You can schedule this script using Task Scheduler to run periodically on any Windows Server in your infrastructure. This way new users and users who have cleared their signature will automatically receive the preconfigured company signature.


Final Remarks

  • If you want to use images, such as logo's, in your signature, use absolute URL's which are publically accessible.
  • Minor alternations to the Where-Object block of the script can change the way it functions. E.g.: reset all user signatures, even those already set previously, or set signatures in which users entered a specific string, such as <insert_signature>, and so on. If you would like to extend or modify the functionality of the script in such a manner but don't know how, please don't hesitate to leave a comment.

Set Mailbox Type to Room, Equipment or Shared in Exchange based on Name with Powershell

Besides regular mailboxes Exchange has the option of flagging mailboxes as a Room or Equipment mailbox. These so called Resource mailboxes can be added to an appointment by which users can use Outlook as a reservation system for conference rooms and video projectors.

To convert regular mailboxes that are used in this manner in an existing environment to Resource mailboxes can be time-consuming. Therefore I wrote a PowerShell script that sets the flag based on the occurence of certain words in the name of the mailbox. This script asumes your shared/resource mailboxes are in their own organizational unit.

Shared mailboxes have the added benefit of not requiring a license in Office 365 as they are represented by a disabled user account. One of the conditions however is that their size remains below 10 gigabytes and it is not possible to use ActiveSync with such accounts.

On to the script. First enable remote PowerShell to your Exchange server for the script session.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange Server>/PowerShell/ -Authentication Kerberos
Import-PSSession $Session

Next declare this simple function to search the name for the occurence of a list of search terms.

function inArray([String]$searchTerm, [Array]$searchArray) {
    ForEach($term in $searchArray) {
        if ($searchTerm -match $term) {
            return $true
        }
    }
    return $false
}

Define the search terms (substrings that are part of the mailbox name) that would define it as a Room or Equipment mailbox.

In this case the terms are in Dutch, but you can replace these with for example: "room", "office", "floor" and so on.

$roomSearchTerms = "ruimte", "kamer", "zaal", "kantoor", "lokaal", "cabine"
$equipmentSearchTerms = "projector", "beamer", "laptop"

Define the OU wherein your shared mailboxes reside.

$organizationalUnit = "OU=Mail,OU=Groups,DC=domain,DC=local"

Finally the query and operations for each mailbox happen here.

$mailboxes = Get-Mailbox -OrganizationalUnit $organizationalUnit -ResultSize Unlimited

ForEach ($mailbox in $mailboxes) {
    if (inArray ($mailbox.Name) $roomSearchTerms) {
        Set-Mailbox -Identity $mailbox.WindowsEmailAddress -Type Room
    } elseif (inArray ($mailbox.Name) $equipmentSearchTerms) {
        Set-Mailbox -Identity $mailbox.WindowsEmailAddress -Type Equipment
    } else {
        Set-Mailbox -Identity $mailbox.WindowsEmailAddress -Type Shared
    }
}

The end result in the Address Book after running the script looks something like this:

Outlook 2013 All Rooms
Great succes! Modify and use at your own risk.

Download the script: setResourceMailboxes.ps1

Fix Exchange 2003 Outlook Web Access (OWA) Compatibility with Internet Explorer 10

Symtoms

Outlook Web Access (OWA) does not display properly on Internet Explorer 10. CSS code is displayed at the top of the page. Javascript doesn't load properly and the list of messages keeps displaying the message "Loading...".


Outlook Web Access (OWA) on Internet Explorer 10

Cause

Outlook Web Access (OWA) is incompatible with Internet Explorer 10.

Solution

You can implement a work-around on the client, or centrally on your Exchange server.

Client Side

  1. Press F12.
  2. Set Browser mode to Internet Explorer 10 Compatibility mode.


Or...


Server Side

Add the HTTP header "X-UA-Compatible: IE=EmulateIE8" to Exchange. This header will instruct Internet Explorer 10 to render Outlook Web Access the "old-fashioned" way.

  1. Open Internet Information Services (IIS) Manager.
  2. Navigate to Websites, Default Websites.
  3. Open Properties for Exchange.
  4. Open the tab HTTP Headers.
  5. Click Add...
  6. Custom header name: "X-UA-Compatible" (without the quotation marks)
  7. Custom header value: "IE=EmulateIE8" (without the quotation marks)
  8. Click OK. 

Custom HTTP header for OWA
You need to restart your webbrowser for the changes to take effect.

Using PowerShell and ExMerge to Export Exchange 2003 Mailboxes to PST

To (bulk) export mailboxes from Exchange 2007 and higher versions you can use the Export-Mailbox command from PowerShell. Exchange 2003 utilizes Microsoft Exchange Server Mailbox Merge Wizard (ExMerge).

Starting ExMerge from PowerShell is possible through the Start-Process command. However, ExMerge requires a few specific parameters, including two files that define your servers and directories, and the mailboxes you want to export respectively.

In the PowerShell script below you can see a working example of how to incorporate ExMerge into PowerShell. After exporting the mailbox, the script renames the PST to <username>_backup.pst and moves it to the user's home directory but you're free to modify this behaviour.

This script depends on the free PowerShell Commands for Active Directory by Quest, which you can download here, and include by configuring your scripting environment, or you by adding the following line to the script:

Add-PSSnapin Quest.ActiveRoles.ADManagement 

Make sure ExMerge and the Exchange System Management Tools (if not run on the Exchange server) are installed and that your account has sufficient permissions to access the mailboxes (accounts must be enabled!). Configure the variables below "# Variables" to match your environment. Specify the user or users who's mailbox you'd like to export in the $usernames variable. Of course you could replace this with a clever query on Active Directory.

# 18-04-2013, D. Thijssen
#
# This script performs the following actions for one or multple users:
#
# 1. Export mailbox contents to .pst file
# 2. Move .pst file to user homedirectory
#
# Prerequisites:
#
# 1. ExMerge must be installed
# 2. Mailbox must be enabled and accessible

# Variables
$exchangeServer = "YOUR_EXCHANGE_SERVER"
$domainController = "YOUR_DOMAIN_CONTROLLER"
$dataDirectoryName = "C:\PowerShell\exportMailbox\"
$iniFile = "C:\PowerShell\exportMailbox\exmerge_batch.ini"
$fileContainingListOfMailboxes = "C:\PowerShell\exportMailbox\mailboxes_batch.txt"
$exMergeLocation = "C:\Program Files\Exchsrvr\bin\ExMerge.exe"

# Array of users to disable (comma-seperated strings containing usernames)
$usernames = "username1", "username2"
foreach ($username in $usernames) {
      if (Test-Path $iniFile) {             Remove-Item $iniFile       }       if (Test-Path $fileContainingListOfMailboxes) {             Remove-Item $fileContainingListOfMailboxes       }       $user = Get-QADUser -SamAccountName $username -IncludeAllProperties       $user.legacyExchangeDN | Out-File $fileContainingListOfMailboxes       "[EXMERGE]",       "SourceServerName=$exchangeServer",       "DomainControllerForSourceServer=$domainController",       "DataDirectoryName=$dataDirectoryName",       "FileContainingListOfMailboxes=$fileContainingListOfMailboxes" | Out-File $iniFile       $arguments = "-b", "-d", "-f $iniFile"       Start-Process -FilePath $exMergeLocation -ArgumentList $arguments -Wait       $source =  $dataDirectoryName + (($user.legacyExchangeDN).Substring(($user.legacyExchangeDN).LastIndexOf("cn=")+3)) + ".pst"       $target = ($user.HomeDirectory) + "\" + ($user.mailnickname) + "_backup.pst"       Move-Item -Path $source -Destination $target       if(Test-Path $source) {             Write-Host "User mailbox could not be exported."       } else {             Write-Host "User mailbox has been exported."       } }
Copyright Dave Thijssen. Powered by Blogger.